package multithreading.Demo7_Thread8Blocl;

public class Fourth
{

    /**
     * 两个对象分别调用锁方法，他们之间没有关联
     * 因为不是同一个对象之间的竞争，所以无需等待锁释放
     */
    public static void main(String[] args) {

        Number4 numberA = new Number4();
        Number4 numberB = new Number4();

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    numberA.getOne();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                numberB.getTwo();
            }
        }).start();
    }


}

class Number4{
    public synchronized void getOne() throws InterruptedException {
        Thread.sleep(3000);
        System.out.println("=====one=====");
    }
    public synchronized void getTwo(){
        System.out.println("=====two=====");
    }
}
